<template>
  <div class="good-item" @click="goodImgClick">
    <img :src="showImg" alt="" @load="imgLoad" />
    <div class="good-text">
      <p>{{ goodItem.title }}</p>
      <div class="price-text">
        <span class="price">{{ goodItem.price }}</span
        >&nbsp;
        <i class="iconfont icon-31shoucang"></i>
        <span class="cfav">{{ goodItem.cfav }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodItem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  computed: {
    showImg() {
      return this.goodItem.image || this.goodItem.show.img
    }
  },
  methods: {
    imgLoad() {
      this.$bus.$emit("imgItemLoad");
    },
    goodImgClick() {
      this.$router.push("/details/" + this.goodItem.iid);
    },
  },
};
</script>

<style scoped>
.good-item {
  width: 48%;
  font-size: 14px;
}

.good-item img {
  width: 100%;
  height: 270px;
  background-size: cover;
}

.good-text > p {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

.good-text .price-text {
  text-align: center;
}

.good-text .price-text > span:first-child {
  color: #ff8e96;
}
</style>